package com.hyperion.blog.controller;

import com.hyperion.blog.common.aop.LogAnnotation;
import com.hyperion.blog.service.CommentsService;
import com.hyperion.blog.vo.params.CommentParam;
import com.hyperion.blog.vo.result.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Hyperion
 */
@RestController
@RequestMapping("/comments")
public class CommentsController {

    @Resource
    private CommentsService commentsService;

    @GetMapping("/article/{id}")
    @LogAnnotation(clazz = "CommentsController", method = "commentsByArticle")
    public Result commentsByArticle(@PathVariable("id") Long articleId) {
        return Result.success(commentsService.commentByArticleId(articleId));
    }

    @PostMapping("/create/change")
    @LogAnnotation(clazz = "CommentsController", method = "createComment")
    public Result createComment(@RequestBody CommentParam commentParam) {
        commentsService.createComment(commentParam);
        return Result.success(null);
    }

}
